package demo_09_25_03;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author:连志鹏
 * @className:work_03
 * @descrption:
 * @date: 2021/9/25 10:06
 * @version: 0.1
 * @since: 1.8
 */
public class work_03 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//    	现在有如下一个数组： int[]  oldArr={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};
//        要求将以上数组中的0项去掉，将不为0的值存入一个新的数组，生成新的数组为
//        int newArr[]={1,3,4,5,6,6,5,4,7,6,7,5};

        int[]  oldArr={1,3,4,5,0,0,6,6,0,5,4,7,6,7,0,5};
        int count = 0;
        for (int i = 0; i < oldArr.length; i++) {
            if(oldArr[i]!=0)
                count++;
        }

        int newArr[] = new int[count];count = 0;
        for (int i = 0; i < oldArr.length; i++) {
            if(oldArr[i]!=0)
            {
                newArr[count] = oldArr[i];
                count++;
            }

        }
        System.out.println(Arrays.toString(newArr));





    }
}
